package com.tyl.service.role;

import com.tyl.dao.BaseDao;
import com.tyl.dao.role.RoleDao;
import com.tyl.dao.role.RoleDaoImpl;
import com.tyl.pojo.Role;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class RoleServiceImpl implements RoleService{
    private RoleDao roleDao;

    public RoleServiceImpl() {
       roleDao=new RoleDaoImpl();
    }
    //获取角色列表
    public List<Role> getRoleList() {

        Connection connection=null;
        List<Role> roleList = null;
        try {
            connection= BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeResource(connection,null,null);
        }
        return roleList;
    }
    @Test
    public  void Test(){
        RoleService roleService=new RoleServiceImpl();
        List<Role> roleList = roleService.getRoleList();
        System.out.println(roleList);
    }
}
